/**
 * 创建人:  @author huangpeng    
 * 创建时间:  2022年04月10日 01:01
 * 项目名称:  lemon-blog
 * 文件名称:  BlAboutController
 * 文件描述:  @Description: 博客关于 的controller
 * 公司名称:  HBlog
 *
 * All rights Reserved, Designed By HBlog 
 * @Copyright: 2021-2022
 *
 */
package com.lemon.blog.system.controller;

import com.lemon.blog.system.domain.BlAbout;
import com.lemon.blog.system.service.IBlAboutService;
import com.lemon.common.core.web.controller.BaseController;
import com.lemon.common.core.web.domain.AjaxResult;
import com.lemon.common.core.web.page.TableDataInfo;
import com.lemon.common.log.annotation.Log;
import com.lemon.common.log.enums.BusinessType;
import com.lemon.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 包名称：com.lemon.admin.web.controller.blog
 * 类名称：BlAboutController
 * 类描述：博客关于 的controller
 * 创建人：@author huangpeng 
 * 创建时间：2022年04月10日 01:01
 */
@RestController
@RequestMapping("/about")
@Api("博客关于管理")
public class BlAboutController extends BaseController {

    @Autowired
    private IBlAboutService aboutService;

    /**
     * 新增
     * @Title: insert
     * @Description: 新增
     * @param about
     * @return: AjaxResult
     * @throws:
     * @author: huangpeng
     * @Date: 2023/4/30 22:22
     */
    @ApiOperation("新增博客关于")
    @RequiresPermissions("blog:about:add")
    @Log(title = "博客关于", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult insert(@RequestBody BlAbout about){
        return toAjax(aboutService.insert(about));
    }

    /**
     * 更新
     * @Title: update
     * @Description: 更新
     * @param about
     * @return: AjaxResult
     * @throws:
     * @author: huangpeng
     * @Date: 2023/4/30 22:22
     */
    @ApiOperation("更新博客关于")
    @RequiresPermissions("blog:about:edit")
    @Log(title = "博客关于", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult update(@RequestBody BlAbout about){
        return toAjax(aboutService.update(about));
    }

    /**
     * 根据id查询
     * @Title: get
     * @Description: 根据id查询
     * @param id
     * @return: AjaxResult
     * @throws:
     * @author: huangpeng
     * @Date: 2023/4/30 22:22
     */
    @ApiOperation("根据id查询博客关于")
    @RequiresPermissions("blog:about:query")
    @RequestMapping(value = "/get/{id}",method = RequestMethod.GET)
    public AjaxResult get(@PathVariable(value = "id") Long id){
        return AjaxResult.success(aboutService.selectByPrimaryKey(id));
    }

    /**
     * 删除
     * @Title: delete
     * @Description: 删除
     * @param ids
     * @return: AjaxResult
     * @throws:
     * @author: huangpeng
     * @Date: 2023/4/30 22:22
     */
    @ApiOperation("根据id删除博客关于")
    @RequiresPermissions("blog:about:remove")
    @Log(title = "关于我的", businessType = BusinessType.DELETE)
    @RequestMapping(value = "/delete/{ids}",method = RequestMethod.DELETE)
    public AjaxResult delete(@PathVariable Long[] ids){
        return toAjax(aboutService.deleteByBatch(ids));
    }

    /**
     * 启用博客关于
     * @Title: enable
     * @Description: 启用博客关于
     * @param id
     * @return: AjaxResult
     * @throws:
     * @author: huangpeng
     * @Date: 2023/4/30 22:22
     */
    @ApiOperation("启用博客关于")
    @RequiresPermissions("blog:about:enble")
    @RequestMapping(value = "/enable/{id}",method = RequestMethod.PUT)
    public AjaxResult enable(@PathVariable Long id){
        aboutService.enableById(id);
        return success();

    }

    /**
     * 弃用博客关于
     * @Title: disable
     * @Description: 弃用博客关于
     * @param id
     * @return: AjaxResult
     * @throws:
     * @author: huangpeng
     * @Date: 2023/4/30 22:24
     */
    @ApiOperation("弃用博客关于")
    @RequiresPermissions("blog:about:disable")
    @RequestMapping(value = "/disable/{id}",method = RequestMethod.PUT)
    public AjaxResult disable(@PathVariable Long id){
        aboutService.disableById(id);
        return success();

    }

    /**
     * 分页查询
     * @Title: list
     * @Description: 分页查询
     * @param about
     * @return: TableDataInfo
     * @throws:
     * @author: huangpeng
     * @Date: 2023/4/30 22:24
     */
    @ApiOperation("分页查询博客关于")
    @RequiresPermissions("blog:about:list")
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    public TableDataInfo list(BlAbout about){
        startPage();
        List<BlAbout> list = aboutService.selectAboutList(about);
        return getDataTable(list);
    }

    /**
     * 获取正在使用的关于
     * @Title: getAboutInfo
     * @Description: 获取正在使用的关于
     * @param
     * @return: AjaxResult
     * @throws:
     * @author: huangpeng
     * @Date: 2022/4/10 1:27
     */
    @ApiOperation("获取启用中的博客关于")
    @RequestMapping(value = "/getAboutInfo",method = RequestMethod.GET)
    public AjaxResult getAboutInfo(){
        BlAbout about=aboutService.read();
        return AjaxResult.success(about);

    }

}


